#!/usr/bin/python
# -*- coding: UTF-8 -*-

import dbus
import dbus.service
import dbus.glib
import gobject

class Light(dbus.service.Object):

   def __init__(self, session_bus):
      dbus.service.Object.__init__(self, session_bus, '/Light')
      self.turned_on = False

   @dbus.service.method(dbus_interface='br.org.cinlug.Turnable')
   def TurnOn(self):
      self.turned_on = True
   
   @dbus.service.method(dbus_interface='br.org.cinlug.Turnable')
   def TurnOff(self):
      self.turned_on = False
   
   @dbus.service.method(dbus_interface='br.org.cinlug.Turnable')
   def IsOn(self):
      return self.turned_on

      
if __name__ == '__main__':
   session_bus = dbus.SessionBus()
   bus_name = dbus.service.BusName('br.org.cinlug', bus=session_bus)

   light = Light(bus_name)

   mainloop = gobject.MainLoop()
   mainloop.run()


